﻿Public Class ViewReservation

    Private Sub ViewReservation_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        UI.SetPlaceHolder(txtsearch)
        UI.FormatDataGrid(DataGridView1)
        loadreserv()
    End Sub
    Private Sub loadreserv()
        Dim sql = <sql>
                    SELECT r.ReservationId,r.ClientId,c.ClientName,rt.ReservationType,r.ReservationTypeId,r.ReservationDate,r.DateIn,r.DateOut,r.TotalRoom 
                    FROM Reservation r
                    INNER JOIN ReservationType rt on rt.ReservationTypeId=r.ReservationTypeId
                    INNER JOIN Client c on c.ClientId=r.ClientId
                    WHERE r.DateIn >= CONVERT (date, GETDATE()) AND r.Active=1
                    AND UPPER(c.ClientName) LIKE UPPER(@S)  
                </sql>
        cmd.Parameters("@s") = "%" + txtsearch.Text + "%"
        DataGridView1.DataSource = cmd.ExecuteDataTable(sql)
    End Sub

    Private Sub txtsearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtsearch.TextChanged
        loadreserv()
    End Sub

    Private Sub btnok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnok.Click
        If DataGridView1.SelectedRows.Count > 0 Then
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub
End Class